home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / cbibcode.arc / FGETC.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-05  |  452 b   |  21 lines

  1. /* fgetc.c */
  2. #include <stdio.h>
  3. main()
  4. {
  5.      int i, c;
  6.      char buffer[81];
  7.      FILE *infile;
  8.     if ((infile = fopen("c:\\autoexec.bat", "r")) == NULL)
  9.     {
  10.         perror ("fopen failed.\n");
  11.         exit(0);
  12.     }
  13.     c= fgetc(infile);
  14.     for (i=0; (i<80) && (feof(infile) == 0) && (c != '\n'); i++)
  15.     {
  16.        buffer[i] = c;
  17.        c= fgetc(infile);
  18.     }
  19.     buffer[i] = '\0';      /* Make a C-style string */
  20.     printf("First line of c:autoexec.bat: %s\n", buffer);
  21. }